/*
* 2010
* Author: Kuznetsov Kirill<kirill.kuznets@gmail.com>
* FasGenetic class
*/

#pragma once

#include <boost/graph/adjacency_list.hpp>
#include <map>
#include "../fas_share.h"

using namespace std;
using namespace boost;

class FasGenetic
{
public:
	static void RemoveCycles(Graph &g,const size_t gen_size,const size_t max_iters);

private:
	static const size_t min = 0;//lowest boundary for fitness function
	static const int m_prob = 10; //Mutation probability in %

    static	void					Evolution       (const Graph& worker, size_t gen_size, size_t max_iters,
													Generation& crnt_gen);//gen_size - Generation size
	static	void					CreateFirstGen	(const Graph& worker,size_t gen_size, Generation& crnt_gen);
	static	void					NewOffspring    (const Graph& worker, Generation& crnt_gen,size_t gen_size);
	static	size_t					EvalMetric      (const GenNumeration& n, const Graph& worker);//evaluate fitness metric
	static	bool					IsLeftward      (const GenNumeration& n, const Edge& e, 
													const Graph& worker);
	static	Vertex					FindVertex      (const GenNumeration& n, size_t num);
    static	void					Crossover       (const GenNumeration& mom, const GenNumeration& dad, 
													const Graph& worker, GenNumeration& child);
	static	void					Mutation        (const GenNumeration& mutant, const Graph& worker, GenNumeration& child);	
	static	const GenNumeration&	RandomNumeration(const Generation& gen, size_t gen_size);
	static	void					AddGenNum		(Generation& gen, const Graph& worker, const GenNumeration& gen_num);
	static	bool					NumBy			(pair<Vertex, size_t> vert_num, size_t num);
	static	bool					Inherited		(size_t i, GenNumeration& child, const GenNumeration& parent, size_t parent_pos);
	static	void					PrintNum		(const GenNumeration& n);
};